package albert3d.gui;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.*;

public class PanelMiniatur extends JScrollPane{

	JPanel panel = new JPanel();

	public PanelMiniatur() {

		panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
		panel.add(new Miniatura("./gfx/noimage.png", 0));
		panel.setBackground(Color.DARK_GRAY);
		panel.setMinimumSize(new Dimension(100, 170));

		this.getVerticalScrollBar().setUnitIncrement(16);
		this.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
		this.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
		this.setRequestFocusEnabled(true);
		this.getViewport().add(panel);
		this.setVisible(true);
	}

	public void odswierz(int liczbaPlikow, String[] listaSciezekPlikow) {

		panel.removeAll();
		if (liczbaPlikow>0) {
			for (int i = 0; i < liczbaPlikow; ++i) {
				panel.add(new Miniatura(listaSciezekPlikow[i], i));
			}	
		} else {
			panel.add(new Miniatura("./gfx/noimage.png", 0));
		}

		panel.repaint();
		getViewport().add(panel);
		
	}

}
